package com.ronx.scs.aspects;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class LoggingAspect {

    @Pointcut("execution(* com.ronx.scs.*.*.*(..))")
    public void methods() {
    }

    // intercept any method execution in the class
    @Before("methods()")
    public void logBeforeMethodExecution(JoinPoint jp) {
        System.out.println("AOP logging -> Before: " + jp.toShortString());
    }

    @AfterThrowing("methods()")
    public void logAfterThrowingMethodExecution(JoinPoint jp) {
        System.out.println("AOP logging -> AfterThrowing: " + jp.toShortString());
    }

    @AfterReturning("methods()")
    public void logAfterReturningMethodExecution(JoinPoint jp) {
        System.out.println("AOP logging -> AfterReturning: " + jp.toShortString());
    }

    @After("methods()")
    public void logAfterMethodExecution(JoinPoint jp) {
        System.out.println("AOP logging -> After: " + jp.toShortString());
    }
}
